# -*-Dockerfile-*-
FROM debian:stretch
RUN apt update && \
    apt install -y build-essential curl libcurl4-openssl-dev libsqlite3-dev pkg-config git wget
RUN wget http://downloads.dlang.org/releases/2.x/2.092.1/dmd_2.092.1-0_amd64.deb -O /tmp/dmd_amd64.deb && \
    dpkg -i /tmp/dmd_amd64.deb
RUN rm -f /tmp/dmd_amd64.deb

COPY . /usr/src/onedrive
RUN cd /usr/src/onedrive/ && \
    ./configure && \
    make clean && \
    make && \
    make install

FROM debian:stretch-slim
ENTRYPOINT ["/entrypoint.sh"]
RUN apt update && \
    apt install -y gosu libcurl3 libsqlite3-0 && \
    rm -rf /var/*/apt && \
    mkdir -p /onedrive/conf /onedrive/data
COPY contrib/docker/entrypoint.sh /
COPY --from=0 /usr/local/bin/onedrive /usr/local/bin/
